package com.utc.cards.common.jade;

import jade.core.behaviours.Behaviour;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import android.content.Intent;

import com.utc.cards.Constants;
import com.utc.cards.table.jade.agent.gameAgent.GameAgent;

public abstract class AbstractGameBehaviour extends Behaviour implements IGameBehaviour
{

    private static final long serialVersionUID = 4022889241349356796L;
    protected static Logger log = LoggerFactory.getLogger(AbstractGameBehaviour.class);
    protected GameAgent agent;

    public AbstractGameBehaviour(GameAgent gameAgent)
    {
        super(gameAgent);
        this.agent = gameAgent;
    }

    @Override
    public void onCardPlayed()
    {
        Intent intent = new Intent(Constants.UPDATE_BOARD);
        log.debug("Sending INTENT " + intent.getAction());

        this.agent.getContext().sendBroadcast(intent);
    }

    @Override
    public void onScoreUpdated()
    {
        Intent intent = new Intent(Constants.UPDATE_SCORE);
        log.debug("Sending INTENT " + intent.getAction());

        this.agent.getContext().sendBroadcast(intent);
    }

    @Override
    public void onFoldWon()
    {
        Intent intent = new Intent(Constants.END_OF_TURN);
        log.debug("Sending INTENT " + intent.getAction());

        this.agent.getContext().sendBroadcast(intent);
    }

    @Override
    public void onPartyOver()
    {
        Intent intent = new Intent(Constants.DISPLAY_WINNER);
        log.debug("Sending INTENT " + intent.getAction());

        this.agent.getContext().sendBroadcast(intent);
    }
}
